package com.chen.web_chat.execption;

import com.chen.web_chat.entity.enumerate.ResultCodeEnum;
import lombok.Data;

@Data
public class MyException extends RuntimeException {
    private Integer code;
    private String message;
    private ResultCodeEnum resultCodeEnum;

    /**
     * 根据枚举构造Result对象
     * @param resultCodeEnum
     */
    public MyException(ResultCodeEnum resultCodeEnum) {
        this.resultCodeEnum = resultCodeEnum;
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }

    /**
     * 根据自定义错误信息构造Result对象
     * @param msg
     */
    public MyException(String msg) {
        this.code = 555;
        this.message = msg;
    }
}
